﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Solution104    
{
    public int MaxDepth(TreeNode root)
    {
       if(root==null) return 0;



        return Math.Max(MaxDepth(root.left), MaxDepth(root.right))+1;
    }
    
}

class Program104
{
    static void Main104(string[] args)
    {
        Solution104 solution = new Solution104();




        int[] preorder = [3,9,20,15,7];
        int[] inorder = [9,3,15,20,7];
        Solution105 solBuildTree = new Solution105();
        TreeNode root = solBuildTree.BuildTree(preorder, inorder);

        Solution102 LevelOrder = new Solution102();
        IList<IList<int>> res = LevelOrder.LevelOrder(root);
        for (int i = 0; i < res.Count; i++)
        {
            for (int j = 0; j < res[i].Count; j++)
            {


                Console.Write(res[i][j] + ",");
            }
            Console.WriteLine();
        }

       int depth= solution.MaxDepth(root);
        Console.WriteLine(depth);
    }
}
